#include "GUIDemoWindow.h"
#include "ui_GUIDemoWindow.h"
#include <QMessageBox>


GUIDemoWindow::GUIDemoWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::GUIDemoWindow),
    wmSide(":/images/wm-side.png"),
    wmSidePressed(":/images/wm-side-pressed.png"),
    prevButtons(0)
{
    ui->setupUi(this);

    ui->AButton->setVisible(false);

    connect( ui->actionQuit, SIGNAL(triggered()), this, SLOT(onQuitClick()) );

}

GUIDemoWindow::~GUIDemoWindow()
{
    delete ui;
}

void GUIDemoWindow::onQuitClick() {
    close();
}

void GUIDemoWindow::setButtons(WiiCIS::ButtonState buttons) {
    if (buttons.isPressed(WiiCIS::BUTTON_B) != prevButtons.isPressed(WiiCIS::BUTTON_B)) {
        if (buttons.isPressed(WiiCIS::BUTTON_B)) {
            ui->BButton->setPixmap( wmSidePressed );
        } else {
            ui->BButton->setPixmap( wmSide );
        }

    }
}

/*void GUIDemoWindow::setBButton(bool pressed) {
    if (pressed) {
        ui->BButton->setPixmap( wmSidePressed );
    } else {
        ui->BButton->setPixmap( wmSide );
    }
}


void GUIDemoWindow::setAButton(bool pressed) {
    ui->AButton->setVisible(pressed);
}*/


void GUIDemoWindow::notifyNoRadio() {
    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setText("WiiCIS did not find a Bluetooth Radio installed on your system, which is required for bluetooth operation.\n\n-Is the radio plugged in/turned on?\n-Have you installed your drivers?\n\nPlease activate your radio and restart this program.");
    msgBox.exec();
}

void GUIDemoWindow::initialize() {
}
